#!/usr/bin/env python3

import numpy as np
from scipy.interpolate import interp1d

# 定义控制点
x = np.array([0, 1, 2, 3, 4])
y = np.array([0, 1, 1.5, 3.5, 4])

# 使用Catmull-Rom样条曲线进行插值
f = interp1d(x, y, kind='cubic')

# 绘制插值后的曲线
import matplotlib.pyplot as plt
xnew = np.linspace(0, 4, num=500, endpoint=True)
plt.plot(x, y, 'o', xnew, f(xnew), '-')
plt.show()
